<template>
    <h3>添加导航</h3>
    <div class="category-form">
        <div class="opt">
            <el-input v-model="input" style="width: 360px; height: 44px; font-size: 16px" placeholder="导航名称" />
        </div>

        <div class="opt">
            <el-button @click="addNavFn" type="primary" size="large">添加导航</el-button>
        </div>
    </div>
</template>


<script setup lang="ts">
import { ref } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus';
import api from '../../api/http'
const input = ref('')

// 添加导航
const addNavFn = async () => {
    let text = input.value;
    // console.log(text);

    if (text === '') {
        ElMessage.error("缺少参数，请检查再提交");
        return false;
    }
    await api.nav_add({ text })
        .then(
            content => {
                // console.log(content)
                let { code, msg } = content;
                // 添加分类名称成功
                if (code == 200) {
                    ElMessage.success(msg);
                    // 重置表单
                    input.value = "";
                }
                else {
                    ElMessage.error(msg)
                }
            }
        )
}


</script>

<style lang="scss">
.category-form {
    .opt {
        margin-top: 15px;
    }

}

.avatar-uploader-icon,
.el-upload-dragger,
.avatar-uploader,
.avatar {
    width: 178px;
    height: 178px;
    display: block;
    padding: 0 !important;
}

.avatar-uploader-icon {
    font-size: 28px;
    color: #8c939d;
    width: 178px;
    height: 178px;
    text-align: center;
    padding: 0 !important;
    line-height: 178px;
}
</style>